/**
 * Created by lijing on 2016-06-22.
 */
$.validator.setDefaults({
    submitHandler: function () {
        save();
    }
});
$(document).ready(function () {
    validate();
    $("#idSave").click(function (e) {
        $.validator.resetForm();
    });
    $("#idSubmit").click(function (e) {
        $.validator.resetForm();
    });
});
function validate() {
    //设置默认属性
    $("#mainForm").validate({
        rules: {
            name: {
                required: true,
                minlength: 1
            }

        },
        messages: {
            name: {
                required: "请输入名称",
                minlength: ""
            }
        }
    });
}
function save() {
    $.post(G_Path.path + "/sys/area/save", $("#mainForm").serialize(), function (text) {
        var data = $.parseJSON(text);
        if (data.success) {
            if ("view" == status) {
                history.back();
            } else {
                window.close();
            }
        } else {
            showDialogMessage(data.msg);
        }
    });

}
